﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using TheControllerRisk.Settings;
using System.Runtime.Serialization;

namespace RiskMan.DataClass.Models
{
    [Serializable]
    public class StopListModel : INotifyPropertyChanged, ISerializable
    {
        #region private
        private bool _check;
        private String _Account;
        private List<String> _AccountList;
        private bool _isStart;
        private String _ClientCode;
        private List<String> _ClientCodeList;

        private String _Seccode;
        private List<String> _SeccodeList;
        private int _currentPos;
        private double _currentPrice;
        private String _TypeStop;
        private String _TypeRasch;
        private Double _StopOtst;
        private Double _StopSprd;
        private Double _TakeOtst;
        private Double _TakeSprd;
        private Double _TakePrAc;
        private Double _Lossless;
        private Double _PriceDeal;
        private String _ClassCode;
        #endregion

        #region public

        public List<String> _TypeStopList = new List<String>( ) 
        {
            cfg.Unknown,
            cfg.StopLimit,
            cfg.TakeProfit,
            cfg.StopTakeOrder,
            cfg.LinkedOrder,
            cfg.TakeProfitLimitOrder
        };
        public List<String> _TypeRaschList = new List<String>( ) 
        {
            cfg.Unknown, 
            cfg.ValutPrice,
            cfg.Persent
        };

        public bool Check
        {
            get { return _check; }
            set
            {
                if ( _check != value )
                {
                    _check = value;
                    RaisePropertyChanged( "Check" );
                }
            }

        }

        public String Account
        {
            get { return _Account; }
            set
            {
                if ( _Account != value )
                {
                    _Account = value;
                    RaisePropertyChanged( "Account" );
                }
            }
        }
        public List<String> AccountList
        {
            get { return _AccountList; }
            set
            {
                if ( _AccountList != value )
                {
                    _AccountList = value;
                    RaisePropertyChanged( "AccountList" );
                }
            }
        }
        public String ClientCode
        {
            get { return _ClientCode; }
            set
            {
                if ( _ClientCode != value )
                {
                    _ClientCode = value;
                    RaisePropertyChanged( "ClientCode" );
                }
            }

        }
        public List<String> ClientCodeList
        {
            get { return _ClientCodeList; }
            set
            {
                if ( _ClientCodeList != value )
                {
                    _ClientCodeList = value;
                    RaisePropertyChanged( "ClientCodeList" );
                }
            }
        }
        public String Seccode
        {
            get { return _Seccode; }
            set
            {
                if ( _Seccode != value )
                {
                    _Seccode = value;
                    RaisePropertyChanged( "Seccode" );
                }
            }
        }

        public String ClassCode
        {
            get { return _ClassCode; }
            set
            {
                if (_ClassCode != value)
                {
                    _ClassCode = value;
                    RaisePropertyChanged("ClassCode");
                }
            }
        }
        
        public List<String> SeccodeList
        {
            get { return _SeccodeList; }
            set
            {
                if ( _SeccodeList != value )
                {
                    _SeccodeList = value;
                    RaisePropertyChanged( "SeccodeList" );
                }
            }
        }
        public int CurrentPos
        {
            get { return _currentPos; }
            set
            {
                if ( _currentPos != value )
                {
                    _currentPos = value;
                    RaisePropertyChanged( "CurrentPos" );
                }
            }
        }
        public double CurrentPrice
        {
            get { return _currentPrice; }
            set
            {
                if ( _currentPrice != value )
                {
                    _currentPrice = value;
                    RaisePropertyChanged( "CurrentPrice" );
                }
            }
        }
        public bool IsStart
        {
            get { return _isStart; }
            set
            {
                if ( _isStart != value )
                {
                    _isStart = value;
                    RaisePropertyChanged( "IsStart" );
                }
            }
        }
        public String TypeStop
        {
            get { return _TypeStop; }
            set
            {
                if ( _TypeStop != value )
                {
                    _TypeStop = value;
                    RaisePropertyChanged( "TypeStop" );
                }
            }
        }
        public String TypeRasch
        {
            get { return _TypeRasch; }
            set
            {
                if ( _TypeRasch != value )
                {
                    _TypeRasch = value;
                    RaisePropertyChanged( "TypeRasch" );
                }
            }
        }
        public Double StopOtst
        {
            get { return _StopOtst; }
            set
            {
                if ( _StopOtst != value )
                {
                    _StopOtst = value;
                    RaisePropertyChanged( "StopOtst" );
                }
            }
        }
        public Double StopSprd
        {
            get { return _StopSprd; }
            set
            {
                if ( _StopSprd != value )
                {
                    _StopSprd = value;
                    RaisePropertyChanged( "StopSprd" );
                }
            }
        }
        public Double TakeOtst
        {
            get { return _TakeOtst; }
            set
            {
                if ( _TakeOtst != value )
                {
                    _TakeOtst = value;
                    RaisePropertyChanged( "TakeOtst" );
                }
            }
        }
        public Double TakeSprd
        {
            get { return _TakeSprd; }
            set
            {
                if ( _TakeSprd != value )
                {
                    _TakeSprd = value;
                    RaisePropertyChanged( "TakeSprd" );
                }
            }
        }
        public Double TakePrAc
        {
            get { return _TakePrAc; }
            set
            {
                if ( _TakePrAc != value )
                {
                    _TakePrAc = value;
                    RaisePropertyChanged( "TakePrAc" );
                }
            }
        }
        public List<String> TypeStopList
        {
            get { return _TypeStopList; }
            set
            {
                if ( _TypeStopList != value )
                {
                    _TypeStopList = value;
                    RaisePropertyChanged( "TypeStopList" );
                }
            }
        }
        public List<String> TypeRaschList
        {
            get { return _TypeRaschList; }
            set
            {
                if ( _TypeRaschList != value )
                {
                    _TypeRaschList = value;
                    RaisePropertyChanged( "TypeRaschList" );
                }
            }
        }
        public Double Lossless
        {
            get { return _Lossless; }
            set
            {
                if ( _Lossless != value )
                {
                    _Lossless = value;
                    RaisePropertyChanged( "Lossless" );
                }
            }
        }
        public Double PriceDeal
        {
            get { return _PriceDeal; }
            set
            {
                if (_PriceDeal != value)
                {
                    _PriceDeal = value;
                    RaisePropertyChanged("PriceDeal");
                }
            }
        }

        #endregion

        #region OnPropertyChanged

        public event PropertyChangedEventHandler PropertyChanged;

        protected void RaisePropertyChanged ( string propertyName )
        {
            var handler = PropertyChanged;
            if ( handler != null )
            {
                handler( this, new PropertyChangedEventArgs( propertyName ) );
            }
        }

        #endregion

        public StopListModel ( ) { }

        public StopListModel ( SerializationInfo info, StreamingContext context )
        {
            Check = info.GetBoolean( "Check" );
            Account = info.GetString( "Account" );
            AccountList = ( List<String> ) info.GetValue( "AccountList", typeof( List<String> ) );
            ClientCode = info.GetString( "ClientCode" );
            ClientCodeList = ( List<String> ) info.GetValue( "ClientCodeList", typeof( List<String> ) );
            Seccode = info.GetString( "Seccode" );
            SeccodeList = ( List<String> ) info.GetValue( "SeccodeList", typeof( List<String> ) );
            TypeStop = info.GetString( "TypeStop" );
            TypeStopList = ( List<String> ) info.GetValue( "TypeStopList", typeof( List<String> ) );
            TypeRasch = info.GetString( "TypeRasch" );
            TypeRaschList = ( List<String> ) info.GetValue( "TypeRaschList", typeof( List<String> ) );
            IsStart = info.GetBoolean( "IsStart" );
            StopOtst = info.GetDouble( "StopOtst" );
            StopSprd = info.GetDouble( "StopSprd" );
            TakeOtst = info.GetDouble( "TakeOtst" );
            TakeSprd = info.GetDouble( "TakeSprd" );
            TakePrAc = info.GetDouble( "TakePrAc" );
            CurrentPos = info.GetInt32( "CurrentPos" );
            CurrentPrice = info.GetDouble( "CurrentPrice" );
            Lossless = info.GetDouble( "Lossless" );
            PriceDeal = info.GetDouble("PriceDeal");
            ClassCode = info.GetString("ClassCode"); 
        }

        public void GetObjectData ( SerializationInfo info, StreamingContext context )
        {
            info.AddValue( "Check", Check );
            info.AddValue( "Account", Account );
            info.AddValue( "AccountList", AccountList );
            info.AddValue( "ClientCode", ClientCode );
            info.AddValue( "ClientCodeList", ClientCodeList );
            info.AddValue( "Seccode", Seccode );
            info.AddValue( "SeccodeList", SeccodeList );
            info.AddValue( "TypeStop", TypeStop );
            info.AddValue( "TypeStopList", TypeStopList );
            info.AddValue( "TypeRasch", TypeRasch );
            info.AddValue( "TypeRaschList", TypeRaschList );
            info.AddValue( "IsStart", IsStart );
            info.AddValue( "StopOtst", StopOtst );
            info.AddValue( "StopSprd", StopSprd );
            info.AddValue( "TakeOtst", TakeOtst );
            info.AddValue( "TakeSprd", TakeSprd );
            info.AddValue( "TakePrAc", TakePrAc );
            info.AddValue( "CurrentPos", CurrentPos );
            info.AddValue( "CurrentPrice", CurrentPrice );
            info.AddValue( "Lossless", Lossless );
            info.AddValue("PriceDeal", PriceDeal);
            info.AddValue("ClassCode", ClassCode);
        }
    }
}